from odoo import models, fields,api

class GanttTask(models.Model):
    _name = 'gantt.task'
    _description = 'Gantt Task'

    name = fields.Char(string="任务名称", required=True)
    start_date = fields.Datetime(string="开始时间", required=True)
    end_date = fields.Datetime(string="结束时间", required=True)
    user_id = fields.Many2one('res.users', string="负责人")
    guanlianids=fields.Many2many('res.users', string="关联任务")
    guanlian_names = fields.Char(string='关联用户名称', compute='_compute_guanlian_names')

    @api.depends('guanlianids')
    def _compute_guanlian_names(self):
        for record in self:
            record.guanlian_names = ', '.join(record.guanlianids.mapped('name'))